-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
It gives me a strange error as if it had conversion problems and converted the StringSource to an object.
const name = 'script.ts';
const source = 'export class Some { }';
const tsc = require('typescript-compiler');
console.log(source, name);
const src = new tsc.StringSource(source, name);
console.log(src);
const js = tsc.compileString(src);
console.log(js);I get this weird error with the codeframe all messed up:
export class Some { } script.ts
StringSource {
contents: 'export class Some { }',
filename: 'script.ts',
type: 1 }
{ sources: {},
sourceMaps: [],
errors: [ 'error TS6053: File \'export class Some { }.ts\' not found.\n' ] }
{ [SyntaxError: script.ts: Unexpected token (1:8)]
pos: 8,
loc: Position { line: 1, column: 8 },
_babel: true,
codeFrame: '\u001b[0m> 1 | \u001b[33m[\u001b[39mobject Object\u001b[33m]\u001b[39m\n | ^\u001b[0m' }
SyntaxError: script.ts: Unexpected token (1:8)
> 1 | [object Object]
| ^
at Parser.pp.raise (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/location.js:22:13)
at Parser.pp.unexpected (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/util.js:91:8)
at Parser.pp.expect (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/util.js:83:33)
at Parser.pp.parseExprList (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:993:12)
at Parser.pp.parseExprAtom (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:476:28)
at Parser.pp.parseExprSubscripts (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:270:19)
at Parser.pp.parseMaybeUnary (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:250:19)
at Parser.pp.parseExprOps (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:180:19)
at Parser.pp.parseMaybeConditional (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:157:19)
at Parser.pp.parseMaybeAssign (/Users/andy/Development/selfstudy-ng2/node_modules/babylon/lib/parser/expression.js:120:19)
{ source: 'export class Some { }',
err:
{ [SyntaxError: script.ts: Unexpected token (1:8)]
pos: 8,
loc: Position { line: 1, column: 8 },
_babel: true,
codeFrame: '\u001b[0m> 1 | \u001b[33m[\u001b[39mobject Object\u001b[33m]\u001b[39m\n | ^\u001b[0m' } }Not sure where to start, sorry.
Metadata
Metadata
Assignees
Labels
No labels