Skip to content

Commit

Permalink
same error with create_program
Browse files Browse the repository at this point in the history
  • Loading branch information
ctaggart committed Dec 31, 2024
1 parent d3b9187 commit 5e9dcdb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
22 changes: 11 additions & 11 deletions test-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let version = ts::version();
println!("typescript version: {version}");

let compilerOptions = ts::CompilerOptions::new();
let programOptions = ts::CreateProgramOptions::new(&["abc.ts".to_string()], &compilerOptions);
let program = ts::create_program2(&programOptions)?;
let compiler_options = ts::CompilerOptions::new();
// let program_options = ts::CreateProgramOptions::new(&["abc.ts".to_string()], &compiler_options);
// let _program = ts::create_program2(&program_options)?;

//
// let host = ts::create_compiler_host(&options, true)?;
// let program = ts::create_program(
// &["abc.ts".to_string()],
// &options,
// &host
// )?;
// println!("program: {:?}", program);
let host = ts::create_compiler_host(&compiler_options, true)?;
// println!("host: {:?}", host);
let program = ts::create_program(
&["abc.ts".to_string()],
&compiler_options,
&host
)?;
println!("program: {:?}", program);
// let _checker = program.get_type_checker()?;
// let _diagnostics = ts::get_pre_emit_diagnostics(&program);
// print node count
Expand Down
21 changes: 18 additions & 3 deletions typescript/src/world.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { System } from 'ts:typescript-system/[email protected]';
// import { TsTypescriptTypescript } from 'interfaces/ts-typescript-typescript';
import * as ts from 'typescript';

export function setSys() {
Expand Down Expand Up @@ -138,15 +139,19 @@ class SourceFile {
inner() {
return this._value;
}
a(){
return "a";
}
}

class TypeChecker {
private _value : ts.TypeChecker;
constructor(value: ts.TypeChecker) {
this._value = value;
}


a(){
return "a";
}
}

function version() {
Expand Down Expand Up @@ -254,7 +259,10 @@ class System2 implements ts.System {

function createCompilerHost(options: CompilerOptions): CompilerHost {
try {
return new CompilerHost(ts.createCompilerHost(options.inner()));
const host = ts.createCompilerHost(options.inner());
// console.log("createCompilerHost host", host);
return new CompilerHost(host);
// return new CompilerHost(ts.createCompilerHost(options.inner()));
} catch (ex) {
throw `createCompilerHost failed: ${ex}`;
}
Expand Down Expand Up @@ -293,6 +301,9 @@ class Diagnostic {
inner() {
return this._value;
}
a(){
return "a";
}
}

export const typescript = {
Expand All @@ -305,4 +316,8 @@ export const typescript = {
createProgram2,
getPreEmitDiagnostics,
CreateProgramOptions,
CompilerHost,
Diagnostic,
SourceFile,
TypeChecker,
}
4 changes: 4 additions & 0 deletions typescript/wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ interface typescript {
get-pre-emit-diagnostics: func(program: borrow<program>) -> list<diagnostic>;

resource type-checker {
a: func() -> string;
}

resource compiler-host {
a: func() -> string;
}

resource diagnostic {
a: func() -> string;
}

resource source-file {
test: func() -> string;
}
}

Expand Down

0 comments on commit 5e9dcdb

Please sign in to comment.