Hi,
I’m trying to move my side project to TypeScript. I’m new to TS. I get this error when added a file with method/function that returns a function (ie Aurelia Store nextStateHistory
). Just adding the file, not even imported in the component, causes the error.
Any idea?
Error when npm start
:
Local aurelia-cli v2.0.0
Starting 'clean'...
Finished 'clean'
Starting 'readProjectConfiguration'...
INFO [Bundle] Manually adding package: 2.3.3 aurelia-bootstrapper
INFO [Bundle] Manually adding package: 1.2.1 aurelia-loader-default
INFO [Bundle] Manually adding package: 1.8.1 aurelia-pal-browser
INFO [Bundle] Manually adding package: 1.0.0 aurelia-testing
INFO [Bundle] Manually adding package: 2.0.16 text
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processJson'...
Starting 'processCSS'...
Starting 'copyFiles'...
Starting 'configureEnvironment'...
Finished 'copyFiles'
Finished 'processJson'
risk - There are upcoming breaking changes: removeDeprecatedGapUtilities
risk - We highly recommend opting-in to these changes now to simplify upgrading Tailwind in the future.
risk - https://tailwindcss.com/docs/upcoming-changes
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
Finished 'buildTypeScript'
Finished 'processCSS'
Starting 'writeBundles'...
INFO [Bundler] Tracing files ...
ERROR [Bundler] Failed to do transforms
INFO [Bundler] Error: Line 8: Unexpected token ...
{
uid: 14,
name: 'writeBundles',
branch: false,
error: Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
},
duration: [ 0, 403833207 ],
time: 1599083299772
}
{
uid: 4,
name: '<series>',
branch: true,
error: Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
},
duration: [ 32, 956520038 ],
time: 1599083299777
}
{
uid: 2,
name: '<series>',
branch: true,
error: Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
},
duration: [ 32, 970438268 ],
time: 1599083299778
}
{
uid: 1,
name: '<series>',
branch: true,
error: Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
},
duration: [ 32, 970994982 ],
time: 1599083299778
}
{
uid: 0,
name: '<series>',
branch: true,
error: Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
},
duration: [ 32, 972759703 ],
time: 1599083299778
}
Error: Line 8: Unexpected token ...
at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
index: 283,
lineNumber: 8,
description: 'Unexpected token ...'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wordpress-theme-builder-aureliajs@0.1.0 start: `au run --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wordpress-theme-builder-aureliajs@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/shafiq/.npm/_logs/2020-09-02T21_48_19_867Z-debug.log
example file:
import { nextStateHistory, StateHistory } from "aurelia-store"
// import { setDeepProp } from "resources/helpers/dictionary-helper"
import { /* Block, Screen, */ State } from "../../state"
/**
* @namespace demoActions
* @description Store actions for Demo Component
*
* @requires aurelia-store/nextStateHistory
* @requires resources/helpers/dictionary-helper/setDeepProp
* @requires ../../state/Block
* @requires ../../state/Screen
* @requires ../../state/State
*/
export const demoActions = {
/**
* @method
* @memberOf demoActions
* @description Sets whether app is in dark mode
*
* @return {Function} Updated state
*/
toggleDarkMode: (state: StateHistory<State>, bool: boolean = false) => {
return nextStateHistory(state, {
...state.present,
isDarkMode: bool,
})
},
/* ... */
}
aurelia skeleton:
npx makes aurelia/v1 PROJECT_NAME --here -s cli-bundler,alameda,typescript,htmlmin,sass,postcss,karma,cypress
tsconfig.json:
{
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
},
"include": [
"src",
"test"
],
"compilerOptions": {
"allowJs": true,
"declaration": false,
"lib": [ "ESNext", "DOM" ],
"removeComments": true,
"sourceMap": true,
"target": "ES2018",
"baseUrl": "src",
"moduleResolution": "Node",
"typeRoots": [ "node_modules/@types" ],
"types": [ "jasmine", "lodash" ],
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true
}
}
Edits:
- Add more details about the problem
- Add solution