Repository navigation
feat: typescript SDK resolve value by reference. - #8824
Conversation
ba03494 to
00cb234
Compare
|
The scan engine error isn't related to this PR so we can ignore that one: https://github.com/dagger/dagger/actions/runs/11723011730/job/32655548946?pr=8824 |
helderco
left a comment
There was a problem hiding this comment.
Overall looks good to me.
All the tests are in a single file. Wouldn't hurt to have a few using multiple files, including with conflicting exported names, which would also see if aliased imports are supported:
import { Foo as Bar } from './foobar'| WithNewFile("/work/src/index.ts", ` | ||
| import { dag, Container, object, func } from "@dagger.io/dagger" | ||
| import { dag, Container, object, func } from "@dagger.io/dagger" |
There was a problem hiding this comment.
I don't understand all these indentation changes 😄
If you use sdkSource instead of WithNewFile it already trims the indentation correctly (heredoc). Otherwise, I'd expect this code to not have any indentation. Right now it's in between those two options.
There was a problem hiding this comment.
I did a global search for tab and replace them with space but it seems I didn't re updated the code after.
There was a problem hiding this comment.
Please don't mark feedback as resolved. It should be the reviewer upon confirming it. Otherwise it's more difficult to keep track of what we need to check for.
In this case the formatting is still all over the place. Doesn't mean I'm going to block because of it, but it's not resolved either.
There was a problem hiding this comment.
Yeah I did a global cleanup of the tab, that's why there's that many changes on the formatting
There was a problem hiding this comment.
I'm not saying there's many formatting changes, I'm saying there's a lot that's misformatted even considering only changed lines. Basically the indentations aren't all right.
So when I said this:
I don't understand all these indentation changes
I didn't mean "why make the change at all", I meant "why change the indentation but not make it right".
9c8f1bf to
e68305e
Compare
Fixes dagger#8676. Refactor typedef resolution to be resolve by reference. The introspection starts from the entrypoint (which is the class named the same as the module) and recursively resolve every references. Refactor the TS compiler API to be abstract with a AST that handle lookups, typedef resolutions and default value resolution. Use `imports` to resolve default value that refers to an exported variable. Add custom introspection error. Improve error handling to point to the line that couldn't be introspected. Add supports for native `enum` keyword and `type` native keyword. Simplify overall code abstractions too minimal. Avoid long abstractions functions. Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Fix primitive type usage error message. Fix UnexportedSignature tests Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
f805f57 to
c63373b
Compare
Signed-off-by: Tom Chauveau <[email protected]>
Add support for non-decorable keywords by resolving declarations by references.
Support native `enum` keyword to define enumeration without decorators.
Example
```ts
enum Example {
A = "A",
B = "B",
}
```
Support native `type` keyword to define type without decorators.
This can be use to define data object or primitive type.
Example
```ts
type Example = {
a: string
b: number
}
type Integer = number
type Foo = string
```
Note: If the type is a data object, all properties will be exposed
to API & CLI.
Support resolution of variable and enumerations as default values if they
are exported by the same module.
Example
```ts
export enum Example {
A = "A",
B = "B",
}
export const defaultValue = "foo"
@object()
class Test {
@func()
defaultEnumVar(value: Example = Example.A): Example {
return value
}
@func
defaultStringVar(value: string = defaultValue): string {
return value
}
}
```
Signed-off-by: Tom Chauveau <[email protected]>
Fixes #8676.
Refactor typedef resolution to be resolve by reference. The introspection starts from the entrypoint (which is the class named the same as the module) and recursively resolve every references.
Refactor the TS compiler API to be abstract with a AST that handle lookups, typedef resolutions and default value resolution.
Use
importsto resolve default value that refers to an exported variable.Add custom introspection error.
Improve error handling to point to the line that couldn't be introspected.
Add supports for native
enumkeyword andtypenative keyword.Simplify overall code abstractions too minimal.
Avoid long abstractions functions.
💡 This is not a breaking change! I want to be compatible with the previous way, just adding new features.
Copy of the changelog
Add support for non-decorable keywords by resolving declarations by references.
Support native
enumkeyword to define enumeration without decorators.Example
Support native
typekeyword to define type without decorators.This can be use to define data object or primitive type.
Example
Note: If the type is a data object, all properties will be exposed
to API & CLI.
Support resolution of variable and enumerations as default values if they
are exported by the same module.
Example