Skip to content

support extends "tstl" object for tsconfig.json in node_modules#1440

Merged
Perryvw merged 4 commits intoTypeScriptToLua:masterfrom
pilaoda:master
May 5, 2023
Merged

support extends "tstl" object for tsconfig.json in node_modules#1440
Perryvw merged 4 commits intoTypeScriptToLua:masterfrom
pilaoda:master

Conversation

@pilaoda
Copy link
Copy Markdown
Contributor

@pilaoda pilaoda commented May 4, 2023

#1436 doesn't handle such case:

{
    "extends": "my-npm-module/tsconfig.dev.json",
}

This PR fix this with ts internal API.

return updateParsedConfigFile(parsedConfigFile);
}

function pathIsRelative(path: string): boolean {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment on this function explaining why we need it and how it's different from path.absolute? Took a lot of mental effort to understand the need for this, and I'm sure I will have forgotten again next week!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First condition path.isAbsolute is for absolute path like D:/my-project/tsconfig.json,
Second condition pathIsRelative is for relative path like ./folder/tsconfig.json,
Final is the npm module path like @pilaoda/ts-config/tsconfig.dev.json

pathIsRelative is simply copy from typescript sourcecode https://github.com/microsoft/TypeScript/blob/c333e14578984d0071da63fc28147f1e6fc43ae0/src/compiler/path.ts#LL95C1-L102C2
to keep consistent with its extends behavior

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found ts just export it but mark internal, so I add declaration for them and use both ts.pathIsAbsolute and ts.pathIsRelative.

…ot relative that it is then a module path that needs to be resolved
@Perryvw Perryvw merged commit 6a37cf1 into TypeScriptToLua:master May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants