-
Notifications
You must be signed in to change notification settings - Fork 39
contextPath relative to CWD and resolvers return readonly array #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think we should consider having @freiksenet @vejrj what do you think? |
Yeah, this looks good. Let's do that. |
if (!contextImport) { | ||
return; | ||
} | ||
const contextDir = path.join(path.dirname(inputPath), contextImport); | ||
const contextDir = path.join(process.cwd(), contextImport); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI for future changes, this is equivalent to path.resolve(contextImport)
factory.createTypeReferenceNode( | ||
factory.createIdentifier("ReadonlyArray"), | ||
[type as ts.TypeNode], | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc, the way to do this with modern TS and through the API is something like:
factory.createTypeOperatorNode(ts.SyntaxKind.ReadonlyKeyword, factory.createArrayTypeNode(type))
Which would produce:
readonly X[]
This reverts commit 0a2968d.
export type ImmutableSet<T> = ReadonlySet<Immutable<T>>; | ||
export type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> }; | ||
|
||
export type PromiseOrValue<T> = Immutable<T> | Promise<Immutable<T>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to wonder how expensive this might be vs the previous inlined solution, when compiling or trying to get instant feedback from the LSP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are other problems with it as well (posted in a separate comment). Let's stick with a simple approach then (at least for now)
Generic immutable seems to be a hard thing to do right (see full discussion in this thread). So, for now we'll have to stick with explicit |
No description provided.